package responsibility.开闭原则.demo_01;

public class MainApplication {

    public static void main(String[] args) {
        GraphicEditor graphicEditor = new GraphicEditor();
        graphicEditor.drawShape(new Rectangle());
        graphicEditor.drawShape(new Circle());
//        graphicEditor.drawShape(new Triangle());
    }
}

class GraphicEditor {

    public void drawShape(Shape s) {
        if (s.m_type == 1) {
            drawRectangle();
        } else if (s.m_type == 2) {
            drawCircle();
        }
//        else if (s.m_type == 3) {
//            drawTriangle();
//        }
    }

    public void drawRectangle() {
        System.out.println("draw rectangle");
    }

    public void drawCircle() {
        System.out.println("draw circle");
    }

//    public void drawTriangle() {
//        System.out.println("draw triangle");
//    }
}

class Shape {
    int m_type;
}

class Rectangle extends Shape {
    Rectangle() {
        super.m_type = 1;
    }
}

class Circle extends Shape {
    Circle() {
        super.m_type = 2;
    }
}

//class Triangle extends Shape {
//    Triangle() {
//        super.m_type = 3;
//    }
//}
